home *** CD-ROM | disk | FTP | other *** search
/ Aminet 39 / Aminet 39 (2000)(Schatztruhe)[!][Oct 2000].iso / Aminet / util / wb / SNDMon.lha / SNDMon / Source / SNDMon.asc next >
Encoding:
Text File  |  2000-07-09  |  3.1 KB  |  143 lines

  1. ;' Based On DMA Monitor - SNG March 1999, HiSoft BASIC, WB2+
  2. WBStartup:NoCli:CloseEd
  3. WbToScreen 0
  4. WBenchToFront_
  5.  
  6. *scr.Screen=Peek.l(Addr Screen(0)) ; get some screen info
  7.  
  8. as.s="C:Audioselect"
  9.  
  10. If Exists(as)
  11.   picasso.b=True
  12. Else
  13.   picasso=False
  14. EndIf
  15.  
  16. BitMap 0,16,6,2    ;create led shapes
  17.   Boxf 0,0,15,5,1
  18.   Boxf 1,1,14,4,0
  19.   Boxf 1,1,2,2,2
  20.   GetaShape 0,0,0,16,6
  21.   Boxf 1,1,14,4,3
  22.   Boxf 1,1,2,2,2
  23.   GetaShape 1,0,0,16,6
  24. Free BitMap 0
  25.  
  26. oldstat.s="0"
  27.  
  28. If ReadFile(0,"S:SNDMon.cfg")  ;load config
  29.   FileInput 0
  30.   winx.w=Val(Edit$(8))
  31.   winy.w=Val(Edit$(8))
  32.   CloseFile 0
  33. Else
  34.   winx=100                     ; set default's if config not found
  35.   winy=100
  36. EndIf
  37.  
  38. If picasso
  39.   ShapeGadget 0,2,2,$0,0,0,1
  40.   ShapeGadget 0,19,2,$0,1,0,1
  41.   ShapeGadget 0,36,2,$0,2,0,1
  42.   ShapeGadget 0,53,2,$0,3,0,1
  43.  
  44.   Dim cmd.s(3)
  45.   cmd(0)=as+" source=amiga set"
  46.   cmd(1)=as+" source=av set"
  47.   cmd(2)=as+" source=cd set"
  48.   cmd(3)=as+" source=linein set"
  49.   Window 0,winx,winy,72,10,$800,"",1,2,0
  50. Else
  51.   Window 0,winx,winy,72,10,$800,"",1,2
  52. EndIf
  53. rp.l=RastPort(0)
  54.  
  55. ;###[ CREATE OUR CUSTOM DRAGBAR! ]################################
  56.  
  57. ;--- As David said, this looks bloody horrible, but it works :)
  58. ;
  59. DEFTYPE.Gadget      *gad
  60. DEFTYPE.NewGadget   ng
  61.  
  62. ;--- some stuff we need :)
  63. ;
  64. *WinAddr = Peek.l(Addr Window(0))
  65. *VisInfo = GetVisualInfoA_(*scr,0)
  66. *gad = CreateContext_(&*GadList)
  67.  
  68. ;--- Create drag bar gadget stuff
  69. ;
  70. ng\ng_LeftEdge  = 0
  71. ng\ng_TopEdge   = 0
  72. ng\ng_Width     = 72
  73. ng\ng_Height    = 10
  74. ng\ng_GadgetText= 0
  75. ng\ng_TextAttr  = 0
  76. ng\ng_GadgetID  = -1
  77.  
  78. ng\ng_Flags     = 0
  79. ng\ng_VisualInfo= *VisInfo
  80. ng\ng_UserData  = 0
  81. *gad = CreateGadgetA_(#GENERIC_KIND, *gad, &ng, 0)
  82.  
  83. *gad\Activation = *gad\Activation | #GACT_IMMEDIATE | #GACT_RELVERIFY
  84. *gad\GadgetType = #GTYP_WDRAGGING | #GTYP_BOOLGADGET
  85. *gad\Flags = *gad\Flags | #GFLG_GADGHNONE
  86.  
  87. ;--- Add our custom dragbar to the window...
  88. ;
  89. AddGList_ *WinAddr,*GadList,-1,-1,0
  90. RefreshGList_ *GadList,*WinAddr,0,-1
  91. GT_RefreshWindow_ *WinAddr,0
  92.  
  93. ;###[ END CREATE OUR CUSTOM DRAGBAR! ]############################
  94.  
  95. SetAPen_ rp,2   ;draw border round window
  96. Move_ rp,0,9
  97. Draw_ rp,0,0
  98. Draw_ rp,71,0
  99. SetAPen_ rp,1
  100. Draw_ rp,71,9
  101. Draw_ rp,1,9
  102.  
  103. Repeat
  104.   stat.s=Right$(Bin$(Peek.w($dff002)),4) ; get DMA information
  105.   If stat<>oldstat                       ; check for change
  106.     chnl.b=4
  107.     For a.b=0 To 3
  108.       If Mid$(stat,chnl,1)="1"           ; get channel status
  109.         WBlit 1,17*a+2,2                 ; if on activate led
  110.       Else
  111.         EraseRect_ rp,17*a+2,2,17*a+18,6 ; if off erase old led
  112.         WBlit 0,17*a+2,2                 ; and draw off led
  113.       EndIf
  114.       chnl-1
  115.     Next
  116.     oldstat.s=stat
  117.   EndIf
  118.   For j=1 To 10                          ; pause about 1/5th second
  119.     WaitTOF_
  120.   Next
  121.   If picasso
  122.     If Event=$40
  123.       Execute_ &cmd(GadgetHit),0,0
  124.       oldstat="0"
  125.     EndIf
  126.   EndIf
  127.   k.s=Inkey$
  128. Until k=Chr$(27)                         ; quit if esc pressed
  129.  
  130. If WriteFile(0,"S:SNDMon.cfg")            ; save current window position
  131.   FileOutput 0
  132.   NPrint WindowX
  133.   NPrint WindowY
  134.   CloseFile 0
  135. EndIf
  136.  
  137. RemoveGList_ *WinAddr,*GadList,-1        ; clean up and bye bye...
  138. FreeGadgets_ *GadList
  139. FreeVisualInfo_ *VisInfo
  140. Free Window 0
  141. End
  142.  
  143.